﻿using System;
using System.Drawing;
using System.Runtime.Serialization;

namespace CI.Organism
{

    [DataContract]
    public class VisualSynapseIO : SynapseIO
    {
        public VisualSynapseIO(string bindingName, string shortName, string description, Guid guid, Guid parentGuid, ChildSynapseIOParentType parentType, ulong xOffset, ulong yOffset, SVSFormatType formatType) : 
            base(bindingName, shortName, description, guid)
        {
            ParentGuid = parentGuid;
            ParentType = parentType;
            XOffset = xOffset;
            YOffset = yOffset;
            FormatType = formatType;
        }

        /// <summary>SynapseIO Parent GUID used to uniquely identify it</summary>
        [DataMember]
        public Guid ParentGuid { get; private set; }

        /// <summary>parent type</summary>
        [DataMember]
        public ChildSynapseIOParentType ParentType { get; private set; }

        [DataMember]
        public ulong XOffset { get; private set; }

        [DataMember]
        public ulong YOffset { get; private set; }

        [DataMember]
        public SVSFormatType FormatType { get; private set; }

        private IVisionSystem _vs;
        public IVisionSystem VS
        {
            get { return _vs; } 
            set
            {
                _vs = value;
                _vs.RegisterCooridanteListerner((int)XOffset,(int)YOffset, FireLocalInput);
            }
        }

        private void FireLocalInput(Color inputvalue, long outputvalue)
        {
            FireInput(outputvalue);
        }
    }
}